/*Diego Lima de Freitas RA: 317632
 *Yuri Souza Padua RA: 317420
 * 
 * Classe que trata o Program
 */

package AST;

import java.util.ArrayList;

public class Program {

   
    private ArrayList<Subroutine> procfuncList;
    private GlobalVarList globalvarList;

    public Program(ArrayList<Subroutine> procfuncList, GlobalVarList globalvarList) {
        this.procfuncList = procfuncList;
        this.globalvarList = globalvarList;
    }

    public void genC(PW pw) {

        pw.out.println("#include <stdio.h>");
        pw.out.println("");
        
        pw.out.println("");        
//        pw.out.println("int getInteger(){");        
//        pw.out.println("int _variavelDoGetInteger;");
//        pw.out.println("scanf("+"%d"+", &_variavelDoGetInteger);" );       
//        pw.out.println("return _variavelDoGetInteger;}");
//        pw.out.println("");

        if (globalvarList != null) {
            globalvarList.genC(pw);
        }

        Subroutine e;
        for(int i = 0; i< procfuncList.size(); i++){
            e = procfuncList.get(i);
            e.genC(pw);
            pw.out.println("");
            pw.out.println("");
        }

    }
}
